// const BASE_URL = "http://localhost:8082"
const BASE_URL = "https://wxmin.szsms.net"

export const uniRequest = (options) => {
    return new Promise((resolve, reject) => {
        uni.request({
            url: BASE_URL + options.url,
            method: options.method || 'GET',
            data: options.data || {},
            success: (res) => {
                if (res.statusCode !== 200) {
                    return uni.showToast({
                        icon: 'error',
                        title: '请求发送失败！',
                        duration: 2000
                    })
                }
                if (res.data.code !== 200) {
                    return uni.showToast({
                        icon: 'error',
                        title: '请求数据失败！',
                        duration: 2000
                    })
                }
                resolve(res.data)
            },
            fail: (err) => {
                return uni.showToast({
                    icon: 'error',
                    title: '请求发送失败！',
                    duration: 2000
                })
                reject(err)
            }
        })
    })
}
